package com.whynot.frame.auth.shiro.interceptor;

import com.whynot.frame.auth.shiro.settings.ShiroSettings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 描    述:注入并发拦截器
 * 创建时间: 2018/07/11
 */
@Configuration
public class WebInterceptorConfig extends WebMvcConfigurerAdapter {

    @Autowired
    ShiroSettings shiroSettings;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        if(shiroSettings.getKickout()){
            //注册自定义拦截器，添加拦截路径和排除拦截路径
            registry.addInterceptor(new KickoutSessionControlInterceptor()).addPathPatterns(shiroSettings.getLoginUrl());
        }
    }
}
